const findDeep = require('deepdash/findDeep'); // mixin Deepdash methods into Lodash
const findValueDeep = require('deepdash/findValueDeep');

let things = {
  things: [
    { name: 'something', good: false },
    {
      name: 'another thing',
      good: true,
      children: [
        { name: 'child thing 1', good: false },
        { name: 'child thing 2', good: true },
        { name: 'child thing 3', good: false },
      ],
    },
    {
      name: 'something else',
      good: true,
      subItem: { name: 'sub-item', good: false },
      subItem2: { name: 'sub-item-2', good: true },
    },
  ],
};

const metaValue = findDeep(things, (value, key, parent, context) => {
  if (key === 'name' && value === 'child thing 1') return true;
});

console.log('first matched meta-value: ', metaValue);

const deepValue = findValueDeep(things, (value, key, parent, context) => {
  if (key === 'name' && value === 'child thing 1') return true;
});

console.log('first matched deep value: ', deepValue);


const findPathDeep = require('deepdash/findPathDeep');

const path = findPathDeep(things, (value, key, parent, context) => {
  if (key === 'name' && value === 'child thing 1') return true;
});

console.log('first matched path value: ', path);
